<script setup lang="ts">
// 引入Excel处理库
import ExcelJS from 'exceljs';

// 座位数据数组，包含选手和助裁员的信息
const userData = [
  {
    "participantsId": "397103183883632192",
    "name": "丁利",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502435",
    "helpExaminersName": "苏柏源",
    "helpExaminersCompanyName": "省高公司",
    "row": 1,
    "column": 1
  },
  {
    "participantsId": "397103183883632196",
    "name": "周德",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502454",
    "helpExaminersName": "张楚平",
    "helpExaminersCompanyName": "路桥公司",
    "row": 2,
    "column": 1
  },
  {
    "participantsId": "397103183883632201",
    "name": "赵雅茹",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502428",
    "helpExaminersName": "刘安晴",
    "helpExaminersCompanyName": "省高公司",
    "row": 3,
    "column": 1
  },
  {
    "participantsId": "397103183883632174",
    "name": "蓝梓铃",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502458",
    "helpExaminersName": "王茜",
    "helpExaminersCompanyName": "南粤交投",
    "row": 4,
    "column": 1
  },
  {
    "participantsId": "397103183883632176",
    "name": "杨锴",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502446",
    "helpExaminersName": "梁远丰",
    "helpExaminersCompanyName": "路桥公司",
    "row": 5,
    "column": 1
  },
  {
    "participantsId": "397103183883632186",
    "name": "苏振聪",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502450",
    "helpExaminersName": "严伟杰",
    "helpExaminersCompanyName": "路桥公司",
    "row": 6,
    "column": 1
  },
  {
    "participantsId": "397103183883632168",
    "name": "郑汉城",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502444",
    "helpExaminersName": "王腾富",
    "helpExaminersCompanyName": "建设公司",
    "row": 7,
    "column": 1
  },
  {
    "participantsId": "397103183883632172",
    "name": "郑丹虹",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502461",
    "helpExaminersName": "黄继超",
    "helpExaminersCompanyName": "南粤交投",
    "row": 8,
    "column": 1
  },
  {
    "participantsId": "397103183883632204",
    "name": "祝微",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502447",
    "helpExaminersName": "李佳辉",
    "helpExaminersCompanyName": "路桥公司",
    "row": 1,
    "column": 2
  },
  {
    "participantsId": "397103183883632181",
    "name": "花景",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502455",
    "helpExaminersName": "刘慧琪",
    "helpExaminersCompanyName": "路桥公司",
    "row": 2,
    "column": 2
  },
  {
    "participantsId": "397103183883632178",
    "name": "陈思敏",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502463",
    "helpExaminersName": "邓玲",
    "helpExaminersCompanyName": "南粤交投",
    "row": 3,
    "column": 2
  },
  {
    "participantsId": "397103183883632173",
    "name": "黄振恒",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502438",
    "helpExaminersName": "余毅",
    "helpExaminersCompanyName": "建设公司",
    "row": 4,
    "column": 2
  },
  {
    "participantsId": "397103183883632197",
    "name": "苏怡琴",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502433",
    "helpExaminersName": "彭文豪",
    "helpExaminersCompanyName": "省高公司",
    "row": 5,
    "column": 2
  },
  {
    "participantsId": "397103183883632169",
    "name": "赵娟",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502445",
    "helpExaminersName": "赖佳佳",
    "helpExaminersCompanyName": "建设公司",
    "row": 6,
    "column": 2
  },
  {
    "participantsId": "397103183883632184",
    "name": "李松铃",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502442",
    "helpExaminersName": "朱家英",
    "helpExaminersCompanyName": "建设公司",
    "row": 7,
    "column": 2
  },
  {
    "participantsId": "397103183883632193",
    "name": "黄渝钧",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502429",
    "helpExaminersName": "秦珊婵",
    "helpExaminersCompanyName": "省高公司",
    "row": 8,
    "column": 2
  },
  {
    "participantsId": "397103183883632177",
    "name": "曾建华",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502452",
    "helpExaminersName": "程富成",
    "helpExaminersCompanyName": "路桥公司",
    "row": 1,
    "column": 3
  },
  {
    "participantsId": "397103183883632185",
    "name": "林嘉根",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502459",
    "helpExaminersName": "申慧满",
    "helpExaminersCompanyName": "南粤交投",
    "row": 2,
    "column": 3
  },
  {
    "participantsId": "397103183883632170",
    "name": "陈思思",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502456",
    "helpExaminersName": "刘曼妮",
    "helpExaminersCompanyName": "南粤交投",
    "row": 3,
    "column": 3
  },
  {
    "participantsId": "397103183883632189",
    "name": "周冬霞",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502460",
    "helpExaminersName": "方南凤",
    "helpExaminersCompanyName": "南粤交投",
    "row": 4,
    "column": 3
  },
  {
    "participantsId": "397103183883632179",
    "name": "陈钊",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502443",
    "helpExaminersName": "席梦骁",
    "helpExaminersCompanyName": "建设公司",
    "row": 5,
    "column": 3
  },
  {
    "participantsId": "397103183883632195",
    "name": "张灿",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502432",
    "helpExaminersName": "张坤兰",
    "helpExaminersCompanyName": "省高公司",
    "row": 6,
    "column": 3
  },
  {
    "participantsId": "397103183883632200",
    "name": "李涛",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502448",
    "helpExaminersName": "李娟秀",
    "helpExaminersCompanyName": "路桥公司",
    "row": 7,
    "column": 3
  },
  {
    "participantsId": "397103183883632180",
    "name": "何训亮",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502464",
    "helpExaminersName": "刘静力",
    "helpExaminersCompanyName": "南粤交投",
    "row": 8,
    "column": 3
  },
  {
    "participantsId": "397103183883632191",
    "name": "黎展华",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502426",
    "helpExaminersName": "何勇",
    "helpExaminersCompanyName": "省高公司",
    "row": 1,
    "column": 4
  },
  {
    "participantsId": "397103183883632183",
    "name": "李淑玉",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502465",
    "helpExaminersName": "黄信诚",
    "helpExaminersCompanyName": "南粤交投",
    "row": 2,
    "column": 4
  },
  {
    "participantsId": "397103183883632188",
    "name": "喻香",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502457",
    "helpExaminersName": "潘柳岑",
    "helpExaminersCompanyName": "南粤交投",
    "row": 3,
    "column": 4
  },
  {
    "participantsId": "397103183883632175",
    "name": "罗丽莎",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502462",
    "helpExaminersName": "李莹",
    "helpExaminersCompanyName": "南粤交投",
    "row": 4,
    "column": 4
  },
  {
    "participantsId": "397103183883632202",
    "name": "林线节",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502449",
    "helpExaminersName": "钟梓豪",
    "helpExaminersCompanyName": "路桥公司",
    "row": 5,
    "column": 4
  },
  {
    "participantsId": "397103183883632187",
    "name": "杨慧",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502451",
    "helpExaminersName": "邓章杰",
    "helpExaminersCompanyName": "路桥公司",
    "row": 6,
    "column": 4
  },
  {
    "participantsId": "397103183883632205",
    "name": "任晓云",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502453",
    "helpExaminersName": "谢莲贵",
    "helpExaminersCompanyName": "路桥公司",
    "row": 7,
    "column": 4
  },
  {
    "participantsId": "397103183883632171",
    "name": "何利钊",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502439",
    "helpExaminersName": "卢楠",
    "helpExaminersCompanyName": "建设公司",
    "row": 8,
    "column": 4
  },
  {
    "participantsId": "397103183883632198",
    "name": "刘端金",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502427",
    "helpExaminersName": "陈海香",
    "helpExaminersCompanyName": "省高公司",
    "row": 1,
    "column": 5
  },
  {
    "participantsId": "397103183883632190",
    "name": "陆家怡",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502440",
    "helpExaminersName": "文幔幔",
    "helpExaminersCompanyName": "建设公司",
    "row": 2,
    "column": 5
  },
  {
    "participantsId": "397103183883632194",
    "name": "邓晓红",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502431",
    "helpExaminersName": "江立宇",
    "helpExaminersCompanyName": "省高公司",
    "row": 3,
    "column": 5
  },
  {
    "participantsId": "397103183883632167",
    "name": "何罡阳",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502436",
    "helpExaminersName": "彭飚",
    "helpExaminersCompanyName": "建设公司",
    "row": 4,
    "column": 5
  },
  {
    "participantsId": "397103183883632199",
    "name": "张颖",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502437",
    "helpExaminersName": "陈丹",
    "helpExaminersCompanyName": "建设公司",
    "row": 5,
    "column": 5
  },
  {
    "participantsId": "397103183883632182",
    "name": "黄扬辉",
    "companyId": "213065246321934337",
    "companyName": "广东省高速公路有限公司",
    "companyShortName": "省高公司",
    "helpExaminersId": "397108814153502441",
    "helpExaminersName": "贺盟",
    "helpExaminersCompanyName": "建设公司",
    "row": 6,
    "column": 5
  },
  {
    "participantsId": "397103183883632203",
    "name": "黄海祥",
    "companyId": "213065246389043217",
    "companyName": "广东省南粤交通投资有限公司",
    "companyShortName": "南粤交投",
    "helpExaminersId": "397108814153502434",
    "helpExaminersName": "谢子康",
    "helpExaminersCompanyName": "省高公司",
    "row": 7,
    "column": 5
  }
]
console.log(userData)
// 定义表格基本参数
const rowCount = 8;  // 总行数
const colCount = 5;  // 总列数
const colSpacing = 1;  // 列间距宽度

// 定义序号填充方式的类型
const numberingType: 'horizontal-ltr' | 'horizontal-rtl' | 'vertical-ltr' | 'vertical-rtl' = 'vertical-ltr';

/**
 * 计算单元格序号的函数
 * @param row 行索引（0开始）
 * @param col 列索引（0开始）
 * @param type 序号填充方式
 * @returns 计算得到的序号值
 */
const calculateCellNumber = (row: number, col: number, type: 'horizontal-ltr' | 'horizontal-rtl' | 'vertical-ltr' | 'vertical-rtl'): number => {
  switch (type) {
    case 'horizontal-ltr': // 横向从左往右填充
      return row * colCount + col + 1;
    case 'horizontal-rtl': // 横向从右往左填充
      return row * colCount + (colCount - col);
    case 'vertical-ltr': // 纵向从左往右填充
      return col * rowCount + row + 1;
    case 'vertical-rtl': // 纵向从右往左填充
      return (colCount - col - 1) * rowCount + row + 1;
    default:
      return 0;
  }
};

/**
 * 导出Excel文件的主函数
 */
const exportExcel = async () => {
  // 创建新的工作簿
  const workbook = new ExcelJS.Workbook();

  // 创建三个不同用途的工作表
  const worksheetAll = workbook.addWorksheet('总表');
  const worksheetParticipants = workbook.addWorksheet('选手表');
  const worksheetHelpers = workbook.addWorksheet('助裁员表');

  /**
   * 创建工作表内容的函数
   * @param worksheet 要处理的工作表
   * @param showParticipants 是否显示选手信息
   * @param showHelpers 是否显示助裁员信息
   */
  const createWorksheet = (worksheet: ExcelJS.Worksheet, showParticipants: boolean, showHelpers: boolean) => {
    // 设置标题行
    const titleRow = worksheet.getRow(1);
    const titleCell = worksheet.getCell('A1');
    titleCell.value = '第三批法律法规座位表';
    titleCell.font = {
      name: '宋体',
      bold: true,
      size: 18
    };
    titleCell.alignment = {
      vertical: 'middle',
      horizontal: 'center'
    };
    // 合并标题行单元格
    worksheet.mergeCells(1, 1, 1, colCount * (4 + colSpacing) - 1);
    titleRow.height = 30;

    // 设置各列的宽度
    for (let i = 0; i < colCount * (4 + colSpacing) - 1; i++) {
      // 判断是否是间隔列
      const isSpacingColumn = Math.floor(i / (4 + colSpacing)) * (4 + colSpacing) + 4 <= i;
      if (isSpacingColumn) {
        worksheet.getColumn(i + 1).width = 2;  // 间隔列宽度
      } else {
        // 根据不同列的用途设置宽度
        const columnIndex = i % (4 + colSpacing);
        switch (columnIndex) {
          case 0:  // "选手/助裁员"标签列
            worksheet.getColumn(i + 1).width = 6;
            break;
          case 1:  // 姓名列
            worksheet.getColumn(i + 1).width = 8;
            break;
          case 2:  // 公司名称列（前半部分）
          case 3:  // 公司名称列（后半部分）
            worksheet.getColumn(i + 1).width = 5;
            break;
          default:
            worksheet.getColumn(i + 1).width = 6;
        }
      }
    }

    // 创建座位表格内容
    for (let row = 0; row < rowCount; row++) {
      for (let col = 0; col < colCount; col++) {
        // 计算当前单元格的序号
        const cellNum = calculateCellNumber(row, col, numberingType);
        // 计算实际的Excel行号（考虑标题行和每个座位占用的行数）
        const baseRow = row * (showParticipants && showHelpers ? 3 : 2) + 2;
        // 计算实际的Excel列号（考虑间隔列）
        const baseCol = col * (4 + colSpacing) + 1;

        // 根据序号计算查找的行列值
        let searchRow, searchCol;
        switch (numberingType as string) {
          case 'horizontal-ltr':
            searchRow = Math.floor((cellNum - 1) / colCount) + 1;
            searchCol = ((cellNum - 1) % colCount) + 1;
            break;
          case 'horizontal-rtl':
            searchRow = Math.floor((cellNum - 1) / colCount) + 1;
            searchCol = colCount - ((cellNum - 1) % colCount);
            break;
          case 'vertical-ltr':
            searchRow = ((cellNum - 1) % rowCount) + 1;
            searchCol = Math.floor((cellNum - 1) / rowCount) + 1;
            break;
          case 'vertical-rtl':
            searchRow = ((cellNum - 1) % rowCount) + 1;
            searchCol = colCount - Math.floor((cellNum - 1) / rowCount);
            break;
          default:
            searchRow = row + 1;
            searchCol = col + 1;
        }

        // 查找对应的数据项
        const item = userData.find(d => d.row === searchRow && d.column === searchCol);

        // 创建序号单元格
        const headerCell = worksheet.getCell(baseRow, baseCol);
        headerCell.value = cellNum < 10 ? `0${cellNum}` : cellNum.toString();
        // 设置序号单元格样式
        headerCell.fill = {
          type: 'pattern',
          pattern: 'solid',
          fgColor: { argb: 'FFFCE4D3' }  // 浅橙色背景
        };
        headerCell.font = {
          name: '微软雅黑',
          bold: true,
          size: 14
        };
        // 设置序号行边框
        headerCell.border = {
          top: { style: 'medium' },
          bottom: { style: 'thin' },
          left: { style: 'medium' },
          right: { style: 'medium' }
        };
        headerCell.alignment = { vertical: 'middle', horizontal: 'center' };
        // 合并序号行的单元格
        worksheet.mergeCells(baseRow, baseCol, baseRow, baseCol + 3);

        // 如果需要显示选手信息
        if (showParticipants) {
          const nameRow = baseRow + 1;
          // 设置"选手"标签
          const nameCell = worksheet.getCell(nameRow, baseCol);
          nameCell.value = '选手';
          // 设置选手姓名
          worksheet.getCell(nameRow, baseCol + 1).value = item?.name || '';
          // 设置选手所属公司
          const companyCell = worksheet.getCell(nameRow, baseCol + 2);
          companyCell.value = item?.companyShortName || '';
          // 合并公司名称单元格
          worksheet.mergeCells(nameRow, baseCol + 2, nameRow, baseCol + 3);

          // 设置选手行的样式
          for (let c = baseCol; c <= baseCol + 3; c++) {
            const cell = worksheet.getCell(nameRow, c);
            cell.fill = {
              type: 'pattern',
              pattern: 'solid',
              fgColor: { argb: 'FFFFFFFF' }  // 白色背景
            };
            cell.font = {
              name: '宋体',
              size: 11
            };
            // 设置选手行边框
            cell.border = {
              top: { style: 'thin' },
              bottom: showHelpers ? { style: 'thin' } : { style: 'medium' },
              left: c === baseCol ? { style: 'medium' } : { style: 'thin' },
              right: c === (baseCol + 3) ? { style: 'medium' } : { style: 'thin' }
            };
            cell.alignment = { vertical: 'middle', horizontal: 'center' };
          }
        }

        // 如果需要显示助裁员信息
        if (showHelpers) {
          // 计算助裁员行号（根据是否显示选手信息来决定）
          const helperRow = showParticipants ? baseRow + 2 : baseRow + 1;
          // 设置"助裁员"标签
          const helperCell = worksheet.getCell(helperRow, baseCol);
          helperCell.value = '助裁员';
          // 设置助裁员姓名
          worksheet.getCell(helperRow, baseCol + 1).value = item?.helpExaminersName || '';
          // 设置助裁员所属公司
          const helperCompanyCell = worksheet.getCell(helperRow, baseCol + 2);
          helperCompanyCell.value = item?.helpExaminersCompanyName || '';
          // 合并公司名称单元格
          worksheet.mergeCells(helperRow, baseCol + 2, helperRow, baseCol + 3);

          // 设置助裁员行的样式
          for (let c = baseCol; c <= baseCol + 3; c++) {
            const cell = worksheet.getCell(helperRow, c);
            cell.fill = {
              type: 'pattern',
              pattern: 'solid',
              fgColor: { argb: 'FFFFFFFF' }  // 白色背景
            };
            cell.font = {
              name: '宋体',
              size: 11
            };
            // 设置助裁员行边框
            cell.border = {
              top: { style: 'thin' },
              bottom: { style: 'medium' },
              left: c === baseCol ? { style: 'medium' } : { style: 'thin' },
              right: c === (baseCol + 3) ? { style: 'medium' } : { style: 'thin' }
            };
            cell.alignment = { vertical: 'middle', horizontal: 'center' };
          }
        }
      }
    }

    // 设置各行的高度
    worksheet.eachRow((row, rowNumber) => {
      if (rowNumber === 1) {
        row.height = 40;  // 标题行高度
      } else if ((rowNumber - 2) % (showParticipants && showHelpers ? 3 : 2) === 0) {
        row.height = 18;  // 序号行高度
      } else {
        row.height = 14;  // 选手和助裁员行高度
      }
    });

    // 添加签名行
    const lastContentRow = rowCount * (showParticipants && showHelpers ? 3 : 2) + 1;
    // 空一行再添加签名
    const signatureRow = worksheet.getRow(lastContentRow + 2);
    const signatureCell = worksheet.getCell(lastContentRow + 2, 1);
    signatureCell.value = '签名：';
    // 设置签名文字样式
    signatureCell.font = {
      name: '宋体',
      bold: true,
      size: 18
    };
    signatureCell.alignment = {
      vertical: 'middle',
      horizontal: 'left'
    };
    // 合并签名行单元格
    worksheet.mergeCells(lastContentRow + 2, 1, lastContentRow + 3, colCount * (4 + colSpacing) - 1);
    // 设置签名行高度
    signatureRow.height = 14;
    worksheet.getRow(lastContentRow + 3).height = 14;
  };

  // 创建三个不同内容的工作表
  createWorksheet(worksheetAll, true, true);  // 总表：显示选手和助裁员
  createWorksheet(worksheetParticipants, true, false);  // 选手表：只显示选手
  createWorksheet(worksheetHelpers, false, true);  // 助裁员表：只显示助裁员

  // 生成并下载Excel文件
  const buffer = await workbook.xlsx.writeBuffer();
  const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = '第三批法律法规座位表.xlsx';
  a.click();
  window.URL.revokeObjectURL(url);
};
</script>

<template>
  <div>
    <el-button type="primary" @click="exportExcel">导出座位表</el-button>
  </div>
</template>

<style scoped></style>
